package com.thouiot.modbus.enums;

/**
 * @description 写入值类型枚举
 * @author wangkai
 * @date 2025/04/14 11:29
 */
public enum WriteValueTypeEnum {
    // coil, coils, register, registers, number
    BOOLEAN("boolean", "单个状态值"),
    SHORT("short", "单个短整型值"),
    NUMBER("number", "数字"),
    BOOLEANS("booleans", "状态值数组"),
    // BYTES("bytes", "byte数组"),
    SHORTS("shorts", "短整型数组"),
    NUMBERS("numbers", "数字数组");
    ;

    private final String code;
    private final String name;

    WriteValueTypeEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static WriteValueTypeEnum getWriteValueTypeEnum(String code) {
        for (WriteValueTypeEnum writeValueTypeEnum : WriteValueTypeEnum.values()) {
            if (writeValueTypeEnum.getCode().equals(code)) {
                return writeValueTypeEnum;
            }
        }
        return null;
    }
}
